package cn.temp

import android.app.Activity
import android.app.Application
import android.content.Context
import android.os.Bundle
import androidx.multidex.MultiDex

/**
 *
 */
class CurrApplication : Application() {
    
    override fun attachBaseContext(base: Context) {
        super.attachBaseContext(base)
        MultiDex.install(this)
    }

    override fun onCreate() {
        super.onCreate()
        sInstance = this

        activityLifeCycle()
    }

    private fun activityLifeCycle() {
        registerActivityLifecycleCallbacks(object : ActivityLifecycleCallbacks {
            override fun onActivityCreated(activity: Activity, savedInstanceState: Bundle?) {
                val simpleName = activity.javaClass.simpleName
                println("dlg $simpleName onActivityCreated")
            }

            override fun onActivityStarted(activity: Activity) {
                val simpleName = activity.javaClass.simpleName
                println("dlg $simpleName onActivityStarted")
            }

            override fun onActivityResumed(activity: Activity) {
                val simpleName = activity.javaClass.simpleName
                println("dlg $simpleName onActivityResumed")
            }

            override fun onActivityPaused(activity: Activity) {
                val simpleName = activity.javaClass.simpleName
                println("dlg $simpleName onActivityPaused")
            }

            override fun onActivityStopped(activity: Activity) {
                val simpleName = activity.javaClass.simpleName
                println("dlg $simpleName onActivityStopped")
            }

            override fun onActivitySaveInstanceState(activity: Activity, outState: Bundle) {
                val simpleName = activity.javaClass.simpleName
                println("dlg $simpleName onActivitySaveInstanceState")
            }

            override fun onActivityDestroyed(activity: Activity) {
                val simpleName = activity.javaClass.simpleName
                println("dlg $simpleName onActivityDestroyed")
            }
        })
    }

    companion object {
        var sInstance: CurrApplication? = null
    }
}
